package com.example.android.story.Utils;

import android.arch.persistence.room.*;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;
import java.util.List;

import static com.example.android.story.R.id.username;

/**
 * Created by android on 18-5-19.
 */

@android.arch.persistence.room.Database(entities = {User.class,Actor.class,Story.class,ActorsInStory.class,Purchased.class,RememberMe.class},version = 1,exportSchema = false)
public abstract class  LocalDatabase extends RoomDatabase{
    public abstract UserDao userDao();
    public abstract StoryDao storyDao();
    public abstract  ActorDao actorDao();
    public abstract  ActorsInStoryDao actorsInStoryDao();
    public abstract  PurchasedDao purchasedDao();
    public abstract  RememberMeDao rememberMeDao();

    private static LocalDatabase INSTANCE;
    static LocalDatabase getDatabase(final Context ctx){
        if(INSTANCE==null){
            synchronized (LocalDatabase.class){
                if(INSTANCE==null){
                    INSTANCE=Room.databaseBuilder(ctx.getApplicationContext()
                            ,LocalDatabase.class
                    ,"database.db").build();
                }
            }
        }
        return INSTANCE;
    }
}